package com.cq.service.impl;

import com.cq.mapper.TopicMapper;
import com.cq.pojo.Topic;
import com.cq.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 悠久的苍穹
 * @Date: 2021/2/2 14:57
 * @Description: ${description}
 * @Version: 1.0
 */
@Service
public class TopicServiceImpl implements TopicService {
    @Autowired
    TopicMapper topicMapper;
    @Override
    public int addTopic(Topic topic) {
        return topicMapper.addTopic(topic);
    }

    @Override
    public List<Topic> getTopics(int page, int limit) {
        return topicMapper.getTopics((page-1)*limit,limit);
    }

    @Override
    public int getCount() {
        return topicMapper.getCount();
    }

    @Override
    public int getTopicCount(String start, String end) {
        return topicMapper.getTopicCount(start,end);
    }

    @Override
    public List<Topic> getTopicsByTime(int page, int limit, String start, String end) {
        return topicMapper.getTopicsByTime((page-1)*limit,limit,start,end);
    }

    @Override
    public List<Topic> getTopicAndReply() {
        return topicMapper.getTopicAndReply();
    }

    @Override
    public void deleteTopicById(int id) {
        topicMapper.deleteTopicById(id);
    }

    @Override
    public Topic getTopicById(int id) {
        return topicMapper.getTopicById(id);
    }

    @Override
    public void updateTopicHot(int id) {
        topicMapper.updateTopicHot(id);
    }

    @Override
    public void updateTopicCold(int id) {
        topicMapper.updateTopicCold(id);
    }

    @Override
    public List<Topic> getHotTopics() {
        return topicMapper.getHotTopics();
    }

    @Override
    public Topic getTopicAndReplyById(int id) {
        return topicMapper.getTopicAndReplyById(id);
    }

    @Override
    public List<Topic> getTopicAndReplyByCreate(String nickName) {
        return topicMapper.getTopicAndReplyByCreate(nickName);
    }
}
